#include<stdio.h>
int main()
{
    int n,m;
    int a,b;
    scanf("%d%d",&n,&m);
    for(a=1;a<=n;a++){
        for(b=1;b<=m;b++){
            if(a==1||b==1||a==n||b==m){
                printf("*");
            }
            else
            {
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}